package com.diamond.service.impl;

import java.util.List;

import com.diamond.bo.FormulaBO;
import com.diamond.po.FormulaPO;
import com.diamond.service.IFormulaService;

/**
 * @author JSmart Tools
 */
@SuppressWarnings("unchecked") 
public class FormulaService extends Service<FormulaPO> implements IFormulaService {

	public Integer countFormulaBo(Long id, Integer start, Integer pageSize) throws Exception {
		String sql="select distinct * from formula as b where b.user_id="+id+" order by importance";
		List totalFormulalist = super.genericDAO.findBySqlToObjForPage(sql, FormulaBO.class, start, pageSize);
		return totalFormulalist.size();
	}

	public FormulaBO findMessageByMessageId(String formulaId) throws Exception {
		String sql = "select distinct * from formula as b where b.formula_id=" + formulaId;
		List<FormulaBO> formulaBolist = super.genericDAO.findBySqlToObj(sql.toString(), FormulaBO.class);
		if (formulaBolist.size() > 0) {
			return formulaBolist.get(0);
		} else {
			return null;
		}
	}
}
